<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
thymeleafUtil
    <a th:href="@{/user}">user</a>
    <a th:href="${#httpServletRequest.getContextPath()+'/user'}">user</a>
</body>
<!-- 根路径 -->
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    let ctxPath1 = /*[[@{/}]]*/ '';
    /*]]>*/
    let ctxPath2 = /*[[@{/}]]*/'';
    let ctxPath3 = /*[[@{/}]]*/'';
    let ctxPath4 =[[${#httpServletRequest.getContextPath()}]];

    console.info(ctxPath1);
    console.info(ctxPath2);
    console.info(ctxPath3);
    console.info(ctxPath4);
</script>
</html>